<?php 
session_start();
if(strlen($_SESSION["u_name"])== 0)
{
 header("Location:index.php");
}
include 'Classes/MyClass.php';
$objMyCass = new MyClass();
$userdetails = array();
$userdetails = $objMyCass->FetchUserRecords($_SESSION["user_id"]);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Excel Data</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="js/jquery-1.4.2.js" type="text/javascript" language="javascript"></script>
<script src="js/ajax.js" type="text/javascript" language="javascript"></script>
<script src="js/tab-view.js" type="text/javascript" language="javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="css/tab-view.css" rel="stylesheet" type="text/css" />
<link href="cssbuttons.css" rel="stylesheet" type="text/css">
<link href="skins/sample/sample.css" rel="stylesheet" type="text/css">

</head>
<body>


<!-- container -->
<div id="container">
	<div class="center">
		<!-- header -->
		<div class="header">
			<div class="logo"><a href="#"><img src="images/logo.png" alt="" /></a></div>
			<div class="login">
				<div class="studentlogin">
					<!-- <h1>Student Login</h1>-->
					<div class="username">
						<!-- <p class="uname">Username:</p> -->
						<div class=""><!-- <input type="text" class="t_box" value="" /> --></div>
					</div>
					<div class="">
						<!-- <p class="uname">Password:</p> -->
						<div class=""><!-- <input type="password" class="t_box" value="" /> --></div>
					</div> 
					
				</div>
				
				<div class="logo1"><a href="#"><img src="images/logo1.png" alt="" /></a></div>
				<div style="text-align:right" >Welcome ,<?php print $_SESSION["u_name"];?>&nbsp;&nbsp;<a href="Logout.php">Log Out</a></div>
			</div>
			<div class="nav">
				<ul>
					<li><a href="Home.php" class="select" >Home</a></li>
					<li><a href="about-us.php">About Us</a></li>
					<li><a href="GmatPreparation.php">GMAT Preperation</a></li> 
					<li><a href="AdmissionConsulting.php">Admissions Consulting</a></li> 
					<li><a href="http://topmbaconsultant.com/forum/">MBA Forum</a></li> 
					<li><a href="contact-us.php">Contact Us</a></li>
				</ul>
			</div>
		</div>
		<!-- header -->
		<!-- middle -->
		
				
		<?php //print_r($_POST);
		$cnt = 0;
		$finalArr = array();
		for($i = 0;$i < count($_REQUEST["ddlBSchool"]);$i++)
		{
		
			$yourGMAT = array();
			$yourGMAT = $objMyCass->ShowIndividualUserGMATDetails($_SESSION["user_id"]);
		
		
			/*$totalyearWE = floor($objMyCass->GetBschoolWorkExperience($_REQUEST["ddlBSchool"][$i])/12);
			$totalmonthWE = ($objMyCass->GetBschoolWorkExperience($_REQUEST["ddlBSchool"][$i])%12);
			
			
			if($totalmonthWE == 0)
			{
				$finalWE = $totalyearWE;
				
			}
			else 
			{
				$finalWE = $totalyearWE.".".$totalmonthWE;
				
			}*/
			
			$finalWE=$objMyCass->GetBschoolWorkExperience($_REQUEST["ddlBSchool"][$i]);
		
			$arrWE = array();
			$objWorkExperience = $objMyCass->ShowIndividualUserWorkHistoryDetails($_SESSION["user_id"]);
			$totalExperience = 0;
			
			foreach($objWorkExperience as &$value1)
			{
				$totalExperience += $value1["experience"];
				
			}
			//$totalyear = floor($totalExperience/12);
			//$totalmonth = $totalExperience%12;
		
			/*if($totalmonth == 0)
			{
				$userWE = $totalyear;
				
			}
			else 
			{*/
				//$userWE = $totalyear.".".$totalmonth;
				//$userWE =$value1["experience"];
				$userWE = $totalExperience;
			//}
			
		
			$totalyearPL = floor($objMyCass->GetBschoolProgramLength($_REQUEST["ddlBSchool"][$i])/12);
			$totalmonthPL = ($objMyCass->GetBschoolProgramLength($_REQUEST["ddlBSchool"][$i])%12);
			
			if($totalmonthPL == 0)
			{
				$finalPL = $totalyearPL;
				
			}
			else 
			{
				$finalPL = $totalyearPL.".".$totalmonthPL;
				
			}
			
		
		$bckyourrank = (20-($i+1))/2;
		$gmatdiff = ((($yourGMAT["score"] -  $objMyCass->GetBschoolAvarageGmatScore($_REQUEST["ddlBSchool"][$i]))/100)*10);
		$wediff = (($userWE - $finalWE )/12)*2;
		$finalcalc = ($bckyourrank + $wediff + $gmatdiff);
		
		$finalArr[] = ($finalcalc * (-1));
			
	
		}
		asort($finalArr);
		//$finalArr = array_reverse($finalArr);
  		$finalArr = array_slice($finalArr, 0,$_SESSION["userchoice"]);  
		
		//print_r($finalArr);
		
?>
		

		<div class="middle">
		
		<table cellpadding="0" cellspacing="0" width="100%" border="0">
		<tr>
		<td colspan="11">&nbsp;</td>		
		</tr>
		
		<tr>
		<td>&nbsp;
		
		</td>	
		<td colspan="10">
		
			<table cellpadding="0" cellspacing="0" >
			<tr>
				<td>
				<b>
					Name
				</b>
				</td>
				<td width="20px">&nbsp;</td>
				<td class="lblText">
				<b>
				<?php $userRecords = $objMyCass->FetchUserRecords($_SESSION["user_id"]);
				print $userRecords["fullname"];
				?>
				</b>
				</td>
			</tr>
			
			<tr>
				<td>
					<b>
					Profile Assesment Score
					</b>
				</td>
				<td width="20px">&nbsp;</td>
				<td class="lblText">
				<b>
					<?php print $_SESSION["application_rating"]." / 10"; ?>
				</b>	
				</td>
			</tr>
			
			<tr>
				<td>
				<b>
					No. of Applications
				</b>
				</td>
				<td width="20px">&nbsp;</td>
				<td class="lblText">
				<b>
					<?php print $_SESSION["userchoice"]; ?>
				</b>	
				</td>
			</tr>
			
			<tr>
			<td colspan="3">&nbsp;</td>
			</tr>
			
			</table>
			
		
		</td>		
		</tr>
		
		<tr>
		
		<table cellpadding="0" cellspacing="0" width="100%" border="1" >
		<tr>
		<td>&nbsp;</td>
		<td>
			<b>School Name</b>
		</td>
		<td>
			<b>Your Rank</b>
		</td>
		<td>
			<b>School Rank</b>
		</td>
		
		<td>
			<b>School Avg GMAT</b>
		</td>
		
		<td>
			<b>Your GMAT</b>
		</td>
		
		<td>
			<b>School Avg years of work ex</b>
				<br />(in yrs)
		</td>
		
		<td>
			<b>Your work ex</b>
				<br />(in yrs)
		</td>
		
		<td>
			<b>Avg Salary</b>
		</td>
		
		<td>
			<b>Program Length</b>
			<br />(in yrs)
		</td>
		
		<td>
			<b>School Recommended</b>
		</td>
		
		</tr>
		<?php //print_r($_POST);
		$cnt = 0;
		for($i = 0;$i < count($_REQUEST["ddlBSchool"]);$i++)
		{?>
		<tr>
		<td class="lblText" align="right"><?php print ($i+1)."."; ?></td>
		<td class="lblText" >
			<?php print $objMyCass->GetBschoolNames($_REQUEST["ddlBSchool"][$i]); ?>
		</td>
		
		<td class="lblText" align="right">
			<?php print ($i+1); ?>
		</td>
		<td class="lblText" align="right">
			<?php print $_REQUEST["ddlBSchool"][$i]; ?>
		</td>
		
		<td class="lblText" align="right">
			<?php print $objMyCass->GetBschoolAvarageGmatScore($_REQUEST["ddlBSchool"][$i]); ?>
		</td>
		
		<td class="lblText" align="right">
			<?php

			$yourGMAT = array();
			$yourGMAT = $objMyCass->ShowIndividualUserGMATDetails($_SESSION["user_id"]);
			print $yourGMAT["score"]; ?>
		</td>
		
		<td class="lblText" align="right">
			<?php 
			$totalyearWE = floor($objMyCass->GetBschoolWorkExperience($_REQUEST["ddlBSchool"][$i])/12);
			$totalmonthWE = ($objMyCass->GetBschoolWorkExperience($_REQUEST["ddlBSchool"][$i])%12);
			
			
			if($totalmonthWE == 0)
			{
				$finalWE = $totalyearWE;
				print $finalWE;
			}
			else 
			{
				$finalWE = $totalyearWE.".".$totalmonthWE;
				print $finalWE; 
			}
			$finalWE2 = $objMyCass->GetBschoolWorkExperience($_REQUEST["ddlBSchool"][$i]);
			?>
		</td>
		
		<td class="lblText" align="right">
			<?php 
			
			$objWorkExperience = $objMyCass->ShowIndividualUserWorkHistoryDetails($_SESSION["user_id"]);
			$totalExperience = 0;
			foreach($objWorkExperience as &$value1)
			{
				$totalExperience += $value1["experience"];
			}
			$totalyear = floor($totalExperience/12);
			$totalmonth = $totalExperience%12;
		
			if($totalmonth == 0)
			{
				$userWE = $totalyear;
				print $userWE;
			}
			else 
			{
				$userWE = $totalyear.".".$totalmonth;
				print $userWE;
			}
			
			$userWE2 = $totalExperience;
			?>
		</td>
		
		<td class="lblText" align="right">
			<?php print "$".number_format(($objMyCass->GetBschoolAvgSalary($_REQUEST["ddlBSchool"][$i])/1000),1)."K";?>
		</td>
		
		<td class="lblText" align="right">
			<?php 
			
			$totalyearPL = floor($objMyCass->GetBschoolProgramLength($_REQUEST["ddlBSchool"][$i])/12);
			$totalmonthPL = ($objMyCass->GetBschoolProgramLength($_REQUEST["ddlBSchool"][$i])%12);
			
			if($totalmonthPL == 0)
			{
				$finalPL = $totalyearPL;
				print $finalPL;
			}
			else 
			{
				$finalPL = $totalyearPL.".".$totalmonthPL;
				print $finalPL; 
			}
			?>
		</td>
		
		<?php 
		
		$bckyourrank = (20-($i+1))/2;
		$gmatdiff = ((($yourGMAT["score"] -  $objMyCass->GetBschoolAvarageGmatScore($_REQUEST["ddlBSchool"][$i]))/100)*10);
		
		$wediff = (($userWE2 - $finalWE2 )/12)*2;
		$finalcalc = ($bckyourrank + $wediff + $gmatdiff);
		$finalcalc2 = (($bckyourrank + $wediff + $gmatdiff)* (-1));

			if($cnt < $_SESSION["userchoice"])
			{
				if(in_array($finalcalc2, $finalArr))
				{
					$background="green";
					$color = "style='color:#fff';";
				}
				else 
				{
					$background="";
					$color = "";
				}
			}
			else 
			{
				$background="";
				$color = "";
			}
		?>
		<td class="lblText" align="center" bgcolor="<?php print $background; ?>" <?php print $color;?> >
		
			<?php 
			if($cnt < $_SESSION["userchoice"])
			{
				if(in_array($finalcalc2, $finalArr))
				{
					$finalArr = $objMyCass->remove_element($finalArr,$finalcalc2);
					
					print "Yes";
					$cnt++;
				}
			}
		?>
			
		</td>
		
		</tr>
		<?php }
		//print $cnt;
		?>
		</table>
		</tr>
		</table>
		<br />
		<div class="cssbutton sample a">
			<input type="button" value="back" onclick="javascript:history.go(-1);" />
		</div>
			
		<div class="bar"><img src="images/ftopbg.png" alt=""/></div>
			</div>
		<!-- /middle -->
		<!-- footer -->
			<div class="footer">
				<ul>
					<li><a href="Home.php">Home</a></li>
					<li>|</li>
					<li><a href="about-us.php">About Us</a></li>
					<li>|</li>
					<li><a href="GmatPreparation.php">GMAT Preperation</a></li>
					<li>|</li>
					<li><a href="AdmissionConsulting.php">Admissions Consulting</a></li>
					<li>|</li>
					<li><a href="http://topmbaconsultant.com/forum/">MBA Blog</a></li>
					<li>|</li>
					<li><a href="contact-us.php">Contact Us</a></li>
				</ul>
			</div>
		<!-- /footer -->
	</div>
</div>
<!-- / container -->
 </body>
</html>